﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Max.PH4.Shoppgin.Admin.Domain
{
    /// <summary>
    /// 物流主表信息
    /// </summary>
    [Table("tb_logistic_master")]
    public class LogisticMasterEntity : AuditField
    {
        public Guid Id { get; set; }

        /// <summary>
        /// 订单号
        /// </summary>
        public string OrderNo { get; set; } //物流和订单号关联（一对一）

        //快递单号
        //时间(快递公司从商品这边什么时间把商品拿走了、什么时候结束)
        //快递状态
        //快递公司名称
        //快递小哥姓名
        //快递小哥电话
        //快递费
        //快递费的结算方式

        /// <summary>
        /// 快递单号
        /// </summary>
        public string DeliveryNo { get; set; } //快递单号

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartDate { get; set; } //开始时间

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndDate { get; set; } //结束时间

        /// <summary>
        /// 快递状态
        /// </summary>
        public string? DeliveryState { get; set; } = "0"; //快递状态(已打包开始、运输中，已完成。。)

        /// <summary>
        /// 快递公司名称
        /// </summary>
        public string? DeliveryCompanyName { get; set; } //快递公司名称（可以设计一张表来维护快递公司）

        /// <summary>
        /// 快递员
        /// </summary>
        public string? DeliveryMan { get; set; }//快递员

        /// <summary>
        /// 快递员电话
        /// </summary>
        public string? DeliveryPhone { get; set; } //快递员电话

        /// <summary>
        /// 快递费
        /// </summary>
        public decimal? DeliveryAmount { get; set; } //快递费

        /// <summary>
        /// 快递费结算方式
        /// </summary>
        public string? DeliverySettleMethod { get; set; }//快递费结算方式


        public LogisticMasterEntity()
        {
            this.DeliveryNo = this.CreateDeliveryNo();
        }

        /// <summary>
        /// 生成快递单号
        /// </summary>
        /// <returns></returns>
        private string CreateDeliveryNo()
        {
            string _dNo = "";
            string _company = "SF";
            string _date = System.DateTime.Now.ToString("yyyyMMdd");
            string _no = new Random().Next(1,9999).ToString().PadLeft(4,'0');
            _dNo = $"{_company}{_date}{_no}";
            return _dNo;
        }
    }
}
